/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package wang.unclecat.dataability.alarm;

import ohos.mp.metadata.binding.databinding.MetaDataBinding;
import ohos.mp.metadata.binding.databinding.MetaDataRequestInfo;
import ohos.mp.metadata.binding.metadata.MetaData;
import ohos.utils.net.Uri;

/**
 * this class wraps alarm database CURD operations.
 *
 * @since 2021-05-15
 */
public class AlarmsMetaDataOperation {

    private static int idx = 0;
    private static int count = 0;
    private static final int DEFAULT_HOUR = 12;
    private static final int DEFAULT_MINUTES = 12;
    private static final int DEFAULT_DAYS_OF_WEEK = 12;
    private static final int DEFAULT_ENABLE = 1;
    private static final int HOURS = 24;
    private static final int MINUTES = 60;
    private static final int ENABLES = 2;
    private static final int DAYS_OF_WEEK = 128;

    private static final String COL_HOUR = "hour";
    private static final String COL_MINUTE = "minutes";
    private static final String COL_ENABLE = "enabled";
    private static final String COL_DAYS = "daysofweek";
    private static final String COL_MSG = "message";

    private AlarmsMetaDataOperation() { }


    /**
     * Create a metadata by binding request information and add into datasource.
     *
     * @param binding meta data binding
     */
    public static void insert(MetaDataBinding binding) {
        MetaDataRequestInfo.RequestItem requestItem = binding.getRequestInfo().getRequestItem("ClockMetaData");

        MetaData metaData = binding.createMetaData(requestItem);
        metaData.put(COL_HOUR, DEFAULT_HOUR);
        metaData.put(COL_MINUTE, DEFAULT_MINUTES);
        metaData.put(COL_DAYS, DEFAULT_DAYS_OF_WEEK);
        metaData.put(COL_ENABLE, DEFAULT_ENABLE);
        metaData.put(COL_MSG, "count" + count);

        binding.addMetaData(metaData, requestItem);
        count++;
    }

}
